<?php

namespace App\Http\Controllers;

use App\Models\Report;
use App\Repositories\FootWorkRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class HomeController extends Controller
{
    public function reportDetail(Request $request,$mall_id)
    {
        $rid = $request->get('rid');
        if(!empty($rid)){
            $report = Report::query()->where('mall_id', $mall_id)
                ->where('wxuser_id', Auth::user()->id)
                ->where('foot_rid',$rid)
                ->first();
        }else{
            $report = Report::query()->where('mall_id', $mall_id)
                ->where('wxuser_id', Auth::user()->id)
                ->orderBy('id','desc')
                ->first();
        }

        if(empty($report)){
            abort(403,'报告不存在');
        }


        return redirect(FootWorkRepository::getShowDetailUrl($report->foot_rid,$report->foot_puid));
    }

    public function hisReport(Request $request)
    {

        return view('home/his_report');
    }
}
